package com.linux.huhx.thread1;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class PriorityThread extends Thread {

    PriorityThread(String name, int priority) {
        super(name);
        setPriority(priority);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                System.out.println(Thread.currentThread().getName() + ", " + i + ", priority = " + Thread.currentThread().getPriority());
                TimeUnit.SECONDS.sleep(new Random().nextInt(5));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
